{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入起始数:  1\n",
      "请输入终止数:  3\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入起始数:  2\n",
      "请输入终止数:  4\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入起始数:  3\n",
      "请输入终止数:  5\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12\n"
     ]
    }
   ],
   "source": [
    "# 1. 累加计算器，输入起始、终止加数，获得结果，多次使用\n",
    "a = 3\n",
    "j = 0\n",
    "while j < a: \n",
    "    s = int(input('请输入起始数: '))\n",
    "    e = int(input('请输入终止数: '))\n",
    "    i = s\n",
    "    r = 0\n",
    "    while i <= e:\n",
    "        r = r + i\n",
    "        i = i + 1\n",
    "    print(r)\n",
    "    j = j + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入N：  3\n",
      " 2\n",
      " 3\n",
      " 4\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9 24 3.0\n"
     ]
    }
   ],
   "source": [
    "# 2. N个数累加、连乘、平均值\n",
    "N = int(input('请输入N： '))\n",
    "i = 0\n",
    "r = 0\n",
    "r1 = 1\n",
    "while i < N:\n",
    "    tmp = int(input())\n",
    "    r = r + tmp\n",
    "    r1 = r1 * tmp\n",
    "    i = i + 1\n",
    "print(r, r1, r/N)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
